

package featureCatalogueManager;

/*
 * #%L
 * catmdedit
 * %%
 * Copyright (C) 2014 Teide
 * %%
 * CatMDEdit 5.0 - Metadata Editor
 * 
 * CatMDEdit has been developed by the The Advanced Information Systems group 
 * of the University of Zaragoza and GeoSpatiumLab S.L.
 * 
 * University of Zaragoza
 * Computer Science and Systems Engineering Department
 * Advanced Information Systems Laboratory (IAAA)
 * http://iaaa.cps.unizar.es/
 * 
 * GeoSpatiumLab S.L.
 * http://www.geoslab.com/
 * 
 * Technical Support
 * 
 * University of Zaragoza
 * Computer Science and Systems Engineering Department
 * Advanced Information Systems Laboratory (IAAA)
 * María de Luna, 1   E-50018 Zaragoza. (Spain)
 * Phone: (34) 976 762134 Fax: (34) 976 761914
 * iaaa@unizar.es   http://iaaa.cps.unizar.es/
 * 
 *  
 * License
 * 
 * The CatMDEdit library is free software; you can redistribute it and/or modify it 
 * under the terms of the GNU Lesser General Public License as published by the 
 * Free Software Foundation; either version 2.1 of the License, or (at your option) 
 * any later version. 
 * This library is distributed in the hope that it will be useful, but WITHOUT ANY 
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
 * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for 
 * more details. 
 * You should have received a copy of the GNU Lesser General Public License along 
 * with this library; if not, write to the Free Software Foundation, Inc., 
 * 51 Franklin St, Fifth Floor, Boston, MA   02110-1301  USA
 *  
 * 
 * Last update: 24 September 2014
 * #L%
 */

import java.awt.event.ActionEvent;
import java.util.EventObject;
import java.util.ResourceBundle;

import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.JButton;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JToolBar;

import metadataManager.metadataEdition.CloseEditorEventObject;

import recordManager.selector.ChangeDatasetSelectedEventObject;
import iaaa.application.AppProperties;
import iaaa.application.Application;
import iaaa.application.component.FCFacade;
import iaaa.application.component.MenuSet;
import iaaa.application.component.ToolBarSet;
//import externalDependency.contactManager.OpenContactSelectorEventObject;

public class FC_featureCatalogueEditor extends FC_featureCatalogueSelector {
	
	// For adding buttons to toolbar and menu
	private Action action_openSelectorForEdition;
	public FC_featureCatalogueEditor() {
		super();
		action_openSelectorForEdition = new AbstractAction(res.getString("label_edition"),
				Application.getProperties().getPropertyAsImageIcon("image_featureCatalogues")) {
			private static final long serialVersionUID = -4035732131463913922L;
			
			public void actionPerformed (ActionEvent e) {
				_activeSelector.setEditable(true);
				_editionMode = true;
				setSelectionEnabled (false);
				setValidationEnabled (false);
				setEditionEnabled (true);				
				_activeSelector.refresh();
				showPanel();
			}
		};
		Application.unSubscribeFromEvent(this,
				OpenFeatureCatalogueSelectorEventObject.class);
	}
	
	public Class getFCFacadeClass() {
		return featureCatalogueManager.FC_featureCatalogueEditor.class;
	}

	public FCFacade getFCFacade() {
		return this;
	}
	
	
	public String getFullName() {
		//return res.getString("FeatureCatalogues_Selector");
		return res.getString("FeatureCatalogues_Selector");
		//COKE HE HECHO UN CAMBIO
	}

	protected ResourceBundle getResourceBundle() {
		return AppProperties.
			getResourceBundle(FC_featureCatalogueEditor.class);
	}

	public String getShortName() {
		//return "FeatureCataloguesEd";
		//mario
	}

	protected boolean manageEvent(EventObject event) {
		return false;
	}

	protected void subscribeToEventChannel() {
		Application.subscribeToEvent(this, 
				CloseEditorEventObject.class);
		Application.subscribeToEvent(this,
				ChangeDatasetSelectedEventObject.class);
	}

	private void setEnableButtons(boolean enable){
		//action_openSelectorForEdition.setEnabled(enable);
		System.out.println("cristina");
	}

		
	public MenuSet getMenuSet () {
		JMenu menu_metadata = new JMenu(res.getString("menu_label"));
		menu_metadata.setName(res.getString("menu_code"));
		menu_metadata.add(action_openSelectorForEdition);
		JMenuBar mb = new JMenuBar();
		mb.add(menu_metadata);
		return new MenuSet(mb);
	}


	public ToolBarSet getToolBarSet () {			
		//JToolBar tb = new JToolBar(res.getString("menu_label"));
		tb.addSeparator();
		JButton editSelector = tb.add(action_openSelectorForEdition);
		editSelector.setToolTipText(res.getString("label_edition"));
		tb.putClientProperty("JToolBar.isRollover", Boolean.TRUE);
		return new ToolBarSet(tb);
		//MODIFICACION METODO DE ANDREA
	}
}
